<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div>
    <ul>
      <li><a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a></li>
    </ul>
  </div>


  <script>
    // 获取全部类数组元素
    let nodeList = document.querySelectorAll('*');
    console.log(nodeList);
    //NodeList(16) [html, head, meta, meta, meta, title, body, div, ul, li, a, a, a, a, a, script]
    console.log(nodeList instanceof Array);
    // false 不是数组

    // 方法1:
    let arr1 = Array.prototype.slice.call(nodeList);
    console.log(arr1 instanceof Array);
    // true 是数组

    // 方法2:
    let arr2 = Array.from(nodeList);
    console.log(arr2 instanceof Array);
    // true 是数组

    // 方法3: 数组扩展符
    let arr3 = [...nodeList];
    console.log(arr3 instanceof Array);
    // true 是数组
  </script>
</body>

</html>